package com.ns002.yigou.quote.common.config;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.lang.reflect.Modifier;

/**
 * @Author xu
 * @Date 2017/7/26 0026 下午 9:25
 * gson配置
 */
@Configuration
public class GsonConfig {

    @Bean("gson")
    public Gson gson() {
        Gson gson = new GsonBuilder()
                .serializeNulls()
                .setDateFormat("yyyy-MM-dd HH:mm:ss")
                .excludeFieldsWithModifiers(Modifier.FINAL, Modifier.TRANSIENT, Modifier.STATIC, Modifier.PROTECTED, Modifier.PUBLIC)
                .create();
        return gson;
    }

}
